home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / pcmag / v10n14 / winclr.exe / WINCOLOR.C next >
Encoding:
C/C++ Source or Header  |  1991-07-20  |  34.3 KB  |  1,146 lines

  1. // wincolor.c RHS 1/25/91
  2.  
  3. #include<windows.h>
  4. #include<stdio.h>
  5. #include<memory.h>
  6. #include<string.h>
  7. #include<stdlib.h>
  8. #include<io.h>
  9.  
  10. #define SC_USER         (0xF000-1)
  11. #define SC_ABOUT        SC_USER
  12. #define SC_AUTOSAVE     SC_USER-1
  13. #define SC_AUTOLOAD     SC_USER-2
  14. #define SC_AUTOPILOT    SC_USER-3
  15. #define SC_AUTOUPDATE   SC_USER-4
  16.  
  17. #define LBUTTONDCLICK   1
  18. #define MY_LBUTTON      0xffff
  19. #define SET     253
  20. #define RESTORE 254
  21. #define SAVE    255
  22. #define HELP    256
  23. #define MYBORDER 2
  24.  
  25. #define WM_MYINIT      (WM_USER + 1)
  26. #define LastChar(s)     (s[strlen(s)-1])
  27.  
  28. #define MAXWINDOWSPARM  256
  29. #define MAXFILENAME     80
  30.  
  31. typedef struct _colorrect
  32.     {
  33.     RECT    r;
  34.     DWORD   color;
  35.     BOOL    solidonly;
  36.     } CRECT;
  37.  
  38. #define MAX_WININICOLORS    19
  39.  
  40.     // offset of first system color
  41. #define CRECTS_SYSCOLORS    2
  42.     // # of system colors
  43. #define MAX_SYSCOLORS       COLOR_ENDCOLORS+1
  44.     // offset of custom colors
  45. #define CRECTS_CUSTCOLORS   CRECTS_SYSCOLORS+19
  46.     // # of custom colors
  47. #define MAX_CUSTCOLORS      36
  48.     // # of rectangles in the dialog (on-screen)
  49. #define MAX_DLGRECTS        CRECTS_CUSTCOLORS+MAX_CUSTCOLORS
  50.     // offset of first Windows color
  51. #define CRECTS_WINCOLORS    MAX_DLGRECTS
  52.  
  53.     // size of rectangle array
  54. #define MAXRECTS    MAX_DLGRECTS+19
  55.  
  56. CRECT *LastWindowPtr = NULL;
  57.  
  58. CRECT CRects[MAXRECTS] =
  59.     {
  60.     { 56, 3, 65, 12, 0x00ffffff, FALSE },          // selected color
  61.     { 4, 24, 46, 62, 0x00ffffff, FALSE },          // work area
  62.  
  63.     { 183,  110, 203, 117, 0x00ffffff, FALSE },    // scroll-bars
  64.     { 183,  126, 203, 133, 0x00ffffff, FALSE },    // desktop b-ground
  65.     { 70,   124, 90,  131, 0x00ffffff, FALSE },    // active titlebar
  66.     { 70,   134, 90,  141, 0x00ffffff, FALSE },    // inactive titlebar
  67.     { 161,  78,  181, 85,  0x00ffffff, TRUE  },    // menu 
  68.     { 70,   96,  90,  103, 0x00ffffff, TRUE  },    // window background
  69.     { 70,   78,  90,  85,  0x00ffffff, TRUE  },    // frame
  70.     { 161,  69,  181, 76,  0x00ffffff, TRUE  },    // menu text
  71.     { 70,   69,  90,  76,  0x00ffffff, TRUE  },    // window text
  72.     { 70,   87,  90,  94,  0x00ffffff, TRUE  },    // caption text
  73.     { 70,   105, 90,  112, 0x00ffffff, FALSE },    // active border
  74.     { 70,   114, 90,  121, 0x00ffffff, FALSE },    // inactive border
  75.     { 183,  134, 203, 141, 0x00ffffff, FALSE },    // application workspace
  76.     { 161,  87,  181, 94,  0x00ffffff, TRUE  },    // menu highlight
  77.     { 161,  96,  181, 103, 0x00ffffff, TRUE  },    // text in menu highlight
  78.     { 241,  126, 261, 133, 0x00ffffff, FALSE },    // button face
  79.     { 241,  136, 261, 143, 0x00ffffff, FALSE },    // button shadow
  80.     { 183,  118, 203, 125, 0x00ffffff, TRUE  },    // grayed text
  81.     { 241,  116, 261, 123, 0x00ffffff, TRUE  },    // button text
  82.  
  83.     { 188, 30, 197, 39, 0x00ffffff, FALSE},        // custom colors
  84.     { 201, 30, 210, 39, 0x00ffffff, FALSE},
  85.     { 214, 30, 223, 39, 0x00ffffff, FALSE},
  86.     { 227, 30, 236, 39, 0x00ffffff, FALSE},
  87.     { 240, 30, 249, 39, 0x00ffffff, FALSE},
  88.     { 253, 30, 262, 39, 0x00ffffff, FALSE},
  89.      
  90.     { 188, 42, 197, 51, 0x00ffffff, FALSE},
  91.     { 201, 42, 210, 51, 0x00ffffff, FALSE},
  92.     { 214, 42, 223, 51, 0x00ffffff, FALSE},
  93.     { 227, 42, 236, 51, 0x00ffffff, FALSE},
  94.     { 240, 42, 249, 51, 0x00ffffff, FALSE},
  95.     { 253, 42, 262, 51, 0x00ffffff, FALSE},
  96.      
  97.     { 188, 54, 197, 63, 0x00ffffff, FALSE},
  98.     { 201, 54, 210, 63, 0x00ffffff, FALSE},
  99.     { 214, 54, 223, 63, 0x00ffffff, FALSE},
  100.     { 227, 54, 236, 63, 0x00ffffff, FALSE},
  101.     { 240, 54, 249, 63, 0x00ffffff, FALSE},
  102.     { 253, 54, 262, 63, 0x00ffffff, FALSE},
  103.      
  104.     { 188, 66, 197, 75, 0x00ffffff, FALSE},
  105.     { 201, 66, 210, 75, 0x00ffffff, FALSE},
  106.     { 214, 66, 223, 75, 0x00ffffff, FALSE},
  107.     { 227, 66, 236, 75, 0x00ffffff, FALSE},
  108.     { 240, 66, 249, 75, 0x00ffffff, FALSE},
  109.     { 253, 66, 262, 75, 0x00ffffff, FALSE},
  110.      
  111.     { 188, 78, 197, 87, 0x00ffffff, FALSE},
  112.     { 201, 78, 210, 87, 0x00ffffff, FALSE},
  113.     { 214, 78, 223, 87, 0x00ffffff, FALSE},
  114.     { 227, 78, 236, 87, 0x00ffffff, FALSE},
  115.     { 240, 78, 249, 87, 0x00ffffff, FALSE},
  116.     { 253, 78, 262, 87, 0x00ffffff, FALSE},
  117.      
  118.     { 188, 90, 197, 99, 0x00ffffff, FALSE},
  119.     { 201, 90, 210, 99, 0x00ffffff, FALSE},
  120.     { 214, 90, 223, 99, 0x00ffffff, FALSE},
  121.     { 227, 90, 236, 99, 0x00ffffff, FALSE},
  122.     { 240, 90, 249, 99, 0x00ffffff, FALSE},
  123.     { 253, 90, 262, 99, 0x00ffffff, FALSE},
  124.  
  125.     { 0,0,0,0, 0x00ffffff, FALSE},                         // Windows colors
  126.     { 0,0,0,0, 0x00ffffff, FALSE},
  127.     { 0,0,0,0, 0x00ffffff, FALSE},
  128.     { 0,0,0,0, 0x00ffffff, FALSE},
  129.     { 0,0,0,0, 0x00ffffff, FALSE},
  130.     { 0,0,0,0, 0x00ffffff, FALSE},
  131.     { 0,0,0,0, 0x00ffffff, FALSE},
  132.     { 0,0,0,0, 0x00ffffff, FALSE},
  133.     { 0,0,0,0, 0x00ffffff, FALSE},
  134.     { 0,0,0,0, 0x00ffffff, FALSE},
  135.     { 0,0,0,0, 0x00ffffff, FALSE},
  136.     { 0,0,0,0, 0x00ffffff, FALSE},
  137.     { 0,0,0,0, 0x00ffffff, FALSE},
  138.     { 0,0,0,0, 0x00ffffff, FALSE},
  139.     { 0,0,0,0, 0x00ffffff, FALSE},
  140.     { 0,0,0,0, 0x00ffffff, FALSE},
  141.     { 0,0,0,0, 0x00ffffff, FALSE},
  142.     { 0,0,0,0, 0x00ffffff, FALSE},
  143.     { 0,0,0,0, 0x00ffffff, FALSE}
  144.          };
  145.  
  146. int colorIndex[19] =
  147. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };
  148.  
  149. DWORD OrgColorVals[19];
  150. RECT SolidRect = { 66, 3, 75, 12 };
  151.  
  152. #define SelectedColor           CRects[0]
  153. #define WorkArea                CRects[1]
  154.  
  155. static char szCopyRight[] = " WinColor, Copyright (C) Richard Hale Shaw, 1991 ";
  156. static char szWinColor[] = "WinColor";
  157.  
  158. static char szAbout[] = "About...";
  159. static char szAutoSave[] = "AutoSave";
  160. static char szAutoLoad[] = "AutoLoad";
  161. static char szAutoPilot[] = "AutoPilot";
  162. static char szAutoUpdate[] = "Update WIN.INI";
  163.  
  164. static char szWinColorIni[] = "WINCOLOR.INI";
  165.  
  166. BOOL Set = FALSE;
  167. BOOL AutoSave = FALSE;
  168. BOOL AutoLoad = FALSE;
  169. BOOL AutoPilot = FALSE;
  170. BOOL AutoUpdate = FALSE;
  171.  
  172. char szAppName[MAXFILENAME];
  173. HCURSOR hNormalCursor, hHourGlassCursor;
  174. HANDLE hPrev;
  175. LPSTR CmdLine;
  176. HANDLE hInst;
  177. HICON WinColorIcon;
  178. HWND WinColorDlg;
  179. FARPROC OldRectProc;
  180. HWND ActiveWindow = NULL;
  181.  
  182. static HWND hRedScroll, hGreenScroll, hBlueScroll;
  183. int SolidTextControlIds[10] = { 215, 217, 219, 221, 231, 233, 235, 236, 247, 241 };
  184. BOOL init2 = FALSE;
  185. FARPROC RectProcPtr;
  186.  
  187. long FAR PASCAL _export WndProc(HWND, WORD, WORD, LONG);
  188. void UpdateSystemMenu(void);
  189. void SelectColor(LONG lParam);
  190. void PaintWorkArea(LONG lParam);
  191. void _PaintWorkArea(DWORD color, BOOL paintrects);
  192. void _PaintCombo(DWORD color);
  193. void _PaintRect(CRECT *crect, DWORD color);
  194. void DlgPaint(HWND hWnd);
  195. void PaintRectSelectedColor(LONG lParam);
  196. void initRECT(RECT *r, float x, float y);
  197. void HScroll(WORD wParam, LONG lParam);
  198. void SetScrollValues(void);
  199. void InitArray(void);
  200. void SetColors(void);
  201. void SaveOrgColors(void);
  202. void RestoreColors(BOOL reset);
  203. void SaveColorsToIni(BOOL changecursor);
  204. void GetColorsFromIni(void);
  205. BOOL IniFile(char *filename,WORD operation);
  206. void Auto_load(void);
  207. void SetColorsFromWinColors(void);
  208. void UpdateWinIni(void);
  209. char *MakeWinDirFileName(char *filename);
  210. void _PaintSolidRect(DWORD color);
  211. BOOL FAR PASCAL _export DialogProc(HWND hDlg, unsigned message, WORD wParam, LONG lParam);
  212. void InitRectProc(HWND hWnd);
  213. long FAR PASCAL RectProc(HWND hWnd, WORD message, WORD wParam, LONG lParam);
  214. void RePaintRect(LONG lParam);
  215.  
  216. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
  217.     LPSTR lpCmdLine, int nCmdShow)
  218.     {
  219.     MSG msg;
  220.     WNDCLASS wndclass;
  221.  
  222.     hPrev = hPrevInstance;
  223.     hInst = hInstance;
  224.     InitArray();        // initialize arrays and read WINCOLOR.INI
  225.     if(AutoPilot)       // if AutoPilot is on, see if any command-line parameters
  226.         {
  227.         char buf[50];
  228.         
  229.         lstrcpy(buf,lpCmdLine); // copy command-line into buf
  230.         if(!strlen(buf))        // if no command-line parameters...
  231.             {
  232.             SetColorsFromWinColors();  // ...set System Colors and get out
  233.             return 0;
  234.             }
  235.         }
  236.  
  237.     SaveOrgColors();    // initialize OrgColorVals from System Colors
  238.  
  239.     if(!hPrevInstance)    
  240.         {
  241.         wndclass.style = CS_DBLCLKS;
  242.         wndclass.lpfnWndProc = WndProc;
  243.         wndclass.cbClsExtra = 0;       
  244.         wndclass.cbWndExtra = DLGWINDOWEXTRA;       
  245.         wndclass.hInstance = hInstance;
  246.         wndclass.hIcon = WinColorIcon = LoadIcon(hInstance,szWinColor);
  247.         wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
  248.         wndclass.hbrBackground = COLOR_WINDOW+1; // 0; // GetStockObject(WHITE_BRUSH); 
  249.         wndclass.lpszMenuName =  NULL;
  250.         wndclass.lpszClassName = szWinColor;
  251.  
  252.         RegisterClass(&wndclass);
  253.         }
  254.  
  255.     hNormalCursor = LoadCursor(NULL, IDC_ARROW);
  256.     hHourGlassCursor = LoadCursor(NULL, IDC_WAIT);
  257.  
  258.     WinColorDlg = CreateDialog(hInstance,szWinColor, 0, NULL);
  259.     GetModuleFileName(GetClassWord(WinColorDlg,GCW_HMODULE),
  260.                 szAppName, MAXFILENAME-1);
  261.     ShowWindow(WinColorDlg, nCmdShow);
  262.  
  263.     while(GetMessage(&msg, NULL, 0, 0))
  264.         {
  265.         if(!WinColorDlg || !IsDialogMessage(WinColorDlg,&msg))
  266.             {
  267.             TranslateMessage(&msg);
  268.             DispatchMessage(&msg);
  269.             }
  270.         }
  271.     return (msg.wParam);
  272.     }
  273.  
  274. long FAR PASCAL _export WndProc(HWND hDlg, unsigned message, WORD wParam,
  275.    LONG lParam)
  276.     {
  277.     static BOOL LB_Dclick = FALSE;
  278.     static LONG templParam;
  279.     static BOOL init = FALSE;
  280.     static HBRUSH SolidTextBrush;
  281.  
  282.     switch(message)
  283.         {
  284.         case WM_CREATE:
  285.             WinColorDlg = hDlg;
  286.             UpdateSystemMenu();
  287.             SolidTextBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
  288.             SetFocus(GetDlgItem(hDlg, SET));
  289.             RectProcPtr = MakeProcInstance((FARPROC)RectProc,hInst);
  290.             break;
  291.  
  292.         case WM_CTLCOLOR:
  293.             if(HIWORD(lParam) == CTLCOLOR_STATIC)
  294.                 {
  295.                 int i;
  296.                 WORD iD = GetDlgCtrlID(LOWORD(lParam));
  297.  
  298.                 for(i = 0; i < 10; i++)
  299.                     if(GetDlgCtrlID(LOWORD(lParam)) == SolidTextControlIds[i])
  300.                         {
  301.                         SetBkColor(wParam,GetSysColor(COLOR_WINDOW));
  302.                         SetTextColor(wParam,0x000000ff);
  303.                         UnrealizeObject(SolidTextBrush);
  304.                         return (DWORD)SolidTextBrush;
  305.                         }
  306.                     // fall thru for all other controls
  307.                 if(!init2 && (iD < 251 && iD > 124))
  308.                     {
  309.                     InitRectProc(LOWORD(lParam));
  310.                     SetFocus(GetDlgItem(hDlg, SET));
  311.                     }
  312.                 return (DWORD)SolidTextBrush;
  313.                 }
  314.  
  315.             if(!init && HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
  316.                 {
  317.                 HWND hw = LOWORD(lParam);
  318.  
  319.                 switch(GetWindowWord(hw,GWW_ID))
  320.                     {
  321.                     case 211:
  322.                         hRedScroll = hw;
  323.                         break;
  324.                     case 212:
  325.                         hGreenScroll = hw;
  326.                         break;
  327.                     case 213:
  328.                         hBlueScroll = hw;
  329.                         break;
  330.                     }
  331.                 if(hRedScroll && hGreenScroll && hBlueScroll)
  332.                     PostMessage(hDlg,WM_MYINIT,0,0L);
  333.                 }
  334.             goto defwindowproc;
  335.  
  336.         case WM_MYINIT:
  337.             {
  338.             if(!init)
  339.                 {
  340.                 SetScrollRange(hRedScroll,SB_CTL,0,255,FALSE);
  341.                 SetScrollRange(hGreenScroll,SB_CTL,0,255,FALSE);
  342.                 SetScrollRange(hBlueScroll,SB_CTL,0,255,FALSE);
  343.                 _PaintWorkArea(WorkArea.color, FALSE);
  344.                 init = TRUE;
  345.                 SetFocus(GetDlgItem(hDlg, SET));
  346.                 }
  347.             }
  348.             break;
  349.  
  350.         case WM_PAINT:
  351.             DlgPaint(hDlg);
  352.             break;
  353.  
  354.         case WM_QUERYENDSESSION:
  355.         case WM_CLOSE:
  356.             {
  357.             if(Set)
  358.                 if(AutoSave || (MessageBox(hDlg,"Save Color Changes?",szWinColor,
  359.                         MB_ICONQUESTION | MB_YESNO) == IDYES))
  360.                     SaveOrgColors();
  361.             SetCursor(hHourGlassCursor);
  362.             SaveColorsToIni(FALSE);
  363.             if(AutoUpdate)
  364.                 UpdateWinIni();
  365.             if(message == WM_QUERYENDSESSION)
  366.                 return 1L;
  367.             else                                // WM_CLOSE
  368.                 DestroyWindow(hDlg);
  369.             }
  370.             break;
  371.  
  372.         case WM_DESTROY:
  373.             WinColorDlg = 0;
  374.             SetCursor(hNormalCursor);
  375.             DeleteObject(SolidTextBrush);
  376.             PostQuitMessage(0);
  377.             break;
  378.  
  379.         case WM_TIMER:                  // timer message
  380.             if(wParam == LBUTTONDCLICK)
  381.                 {
  382.                 KillTimer(hDlg,LBUTTONDCLICK);
  383.                 if(!LB_Dclick)
  384.                     SendMessage(hDlg,WM_LBUTTONDOWN,MY_LBUTTON,templParam);
  385.                 else
  386.                     LB_Dclick = FALSE;
  387.                 break;
  388.                 }
  389.             break;
  390.  
  391.         case WM_RBUTTONDOWN:
  392.             PaintRectSelectedColor(lParam);
  393.             break;
  394.             
  395.         case WM_LBUTTONDOWN: 
  396.             if(wParam == MY_LBUTTON)
  397.                 SelectColor(lParam);
  398.             else
  399.                 {
  400.                 LB_Dclick = FALSE;
  401.                 templParam = lParam;
  402.                 SetTimer(hDlg,LBUTTONDCLICK,GetDoubleClickTime(),NULL);
  403.                 }
  404.             break;
  405.  
  406.         case WM_LBUTTONDBLCLK:          // left button Double click
  407.             LB_Dclick = TRUE;
  408.             PaintWorkArea(lParam);
  409.             break;
  410.  
  411.         case WM_MENUCHAR:
  412.             {
  413.             if(LastWindowPtr == NULL)
  414.                 break;
  415.             lParam = MAKELONG(LastWindowPtr->r.left,LastWindowPtr->r.top);
  416.             switch(wParam)
  417.                 {
  418.                 case 0x61:  // Alt-A
  419.                 case 0x41:
  420.                     SendMessage(WinColorDlg,WM_COMMAND,SAVE,0L);
  421.                     return 0;
  422.                 case 0x68:  // Alt-H
  423.                 case 0x48:
  424.                     SendMessage(WinColorDlg,WM_COMMAND,HELP,0L);
  425.                     return 0;
  426.                 case 0x70:  // Alt-P
  427.                 case 0x50:
  428.                     SendMessage(WinColorDlg,WM_RBUTTONDOWN,0,lParam);
  429.                     return 0;
  430.                 case 0x72:  // Alt-R
  431.                 case 0x52:
  432.                     SendMessage(WinColorDlg,WM_COMMAND,RESTORE,0L);
  433.                     return 0;
  434.                 case 0x73:  // Alt-S
  435.                 case 0x53:
  436.                     SendMessage(WinColorDlg,WM_LBUTTONDOWN,MY_LBUTTON,lParam);
  437.                     return 0;
  438.                 case 0x74:  // Alt-T
  439.                 case 0x54:
  440.                     SendMessage(WinColorDlg,WM_COMMAND,SET,0L);
  441.                     return 0;
  442.                 case 0x77:  // Alt-W
  443.                 case 0x57:
  444.                     SendMessage(WinColorDlg,WM_LBUTTONDBLCLK,0,lParam);
  445.                     return 0;
  446.                 default:
  447.                     break;
  448.                 }
  449.             }
  450.             break;
  451.  
  452.         case WM_ACTIVATE:
  453.             if(!wParam)             // window is inactive, save focus
  454.                 ActiveWindow = GetFocus();
  455.             else                    // window is being activated, set focus
  456.                 {
  457.                 if(ActiveWindow)
  458.                     SetFocus(ActiveWindow);
  459.                 else
  460.                     SetFocus(GetDlgItem(hDlg, SET));
  461.                 }
  462.             break;
  463.  
  464.         case WM_HSCROLL:
  465.             {
  466.             BYTE red,green,blue;
  467.  
  468.             HScroll(wParam,lParam);
  469.             red = (BYTE)GetScrollPos(hRedScroll,SB_CTL);
  470.             green = (BYTE)GetScrollPos(hGreenScroll,SB_CTL);
  471.             blue = (BYTE)GetScrollPos(hBlueScroll,SB_CTL);
  472.             _PaintCombo(RGB(red,green,blue));
  473.             SetScrollValues();
  474.             }
  475.             break;
  476.  
  477.         case WM_COMMAND:
  478.             switch(wParam)
  479.                 {
  480.                 case SET:
  481.                     Set = TRUE;
  482.                     SetColors();
  483.                     return 0L;
  484.                 case RESTORE:
  485.                     RestoreColors(TRUE);
  486.                     Set = FALSE;
  487.                     return 0L;
  488.                 case SAVE:
  489.                     SaveColorsToIni(TRUE);
  490.                     return 0L;
  491.                 case HELP:
  492.                     {
  493. #if defined(__BORLANDC__)
  494.                     DialogBox(hInst, "WinColorHelp", hDlg, (FARPROC)DialogProc);
  495. #else
  496.                     FARPROC lpDlgProc = MakeProcInstance((FARPROC)DialogProc,hInst);
  497.                     DialogBox(hInst, "WinColorHelp", hDlg, lpDlgProc);
  498.                     FreeProcInstance(lpDlgProc);
  499. #endif
  500.                     SetFocus(GetDlgItem(hDlg, HELP));
  501.                     return 0L;
  502.                     }
  503.  
  504.                 default:
  505.                     if(HIWORD(lParam) == EN_SETFOCUS)
  506.                         {
  507.                         RECT rect;
  508.                         HDC hDC = GetDC(LOWORD(lParam));
  509.                         GetClientRect(LOWORD(lParam),&rect);
  510.                         rect.top -= 2;
  511.                         rect.left -= 2;
  512.                         rect.right += 2;
  513.                         rect.bottom += 2;
  514.  
  515.                         Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom);
  516.                         ReleaseDC(LOWORD(lParam),hDC);
  517.                         }
  518.                     return 0L;
  519.                 }
  520.  
  521.         case WM_INITMENU:           // modify the system menu
  522.             CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  523.                 SC_AUTOSAVE,
  524.                 (MF_BYCOMMAND | (AutoSave ? MF_CHECKED : MF_UNCHECKED)));
  525.             CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  526.                 SC_AUTOLOAD,
  527.                 (MF_BYCOMMAND | (AutoLoad ? MF_CHECKED : MF_UNCHECKED)));
  528.             CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  529.                 SC_AUTOPILOT,
  530.                 (MF_BYCOMMAND | (AutoPilot ? MF_CHECKED : MF_UNCHECKED)));
  531.             CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  532.                 SC_AUTOUPDATE,
  533.                 (MF_BYCOMMAND | (AutoUpdate ? MF_CHECKED : MF_UNCHECKED)));
  534.             break;
  535.  
  536.         case WM_SYSCOMMAND:
  537.             switch(wParam)
  538.                 {
  539.                 case SC_ABOUT:
  540.                     {
  541. #if defined(__BORLANDC__)
  542.                     DialogBox(hInst, "ABOUTBOX", hDlg, (FARPROC)DialogProc);
  543. #else
  544.                     FARPROC lpDlgProc = MakeProcInstance((FARPROC)DialogProc,hInst);
  545.                     DialogBox(hInst, "ABOUTBOX", hDlg, lpDlgProc);
  546.                     FreeProcInstance(lpDlgProc);
  547. #endif
  548.                     break;
  549.                     }
  550.  
  551.                 case SC_AUTOLOAD:
  552.                     Auto_load();
  553.                     break;
  554.  
  555.                 case SC_AUTOSAVE:
  556.                     AutoSave = !AutoSave;
  557.                     CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  558.                         SC_AUTOSAVE,(MF_BYCOMMAND |
  559.                             (AutoSave ? MF_CHECKED : MF_UNCHECKED)));
  560.                     break;;
  561.  
  562.                 case SC_AUTOPILOT:
  563.                     AutoPilot = !AutoPilot;
  564.                     CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  565.                         SC_AUTOPILOT,(MF_BYCOMMAND |
  566.                             (AutoPilot ? MF_CHECKED : MF_UNCHECKED)));
  567.                     break;
  568.                 case SC_AUTOUPDATE:
  569.                     AutoUpdate = !AutoUpdate;
  570.                     CheckMenuItem(GetSystemMenu(WinColorDlg,0),
  571.                         SC_AUTOUPDATE,(MF_BYCOMMAND |
  572.                             (AutoUpdate ? MF_CHECKED : MF_UNCHECKED)));
  573.                     break;
  574.  
  575.                 default:
  576.                     goto defwindowproc;
  577.                 }
  578.             break;
  579.  
  580.         default:
  581. defwindowproc:
  582.             return DefWindowProc(hDlg,message,wParam,lParam);
  583.         }
  584.     return 0L;
  585.     }
  586.  
  587. long FAR PASCAL RectProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
  588.     {
  589.     if(message == WM_SETFOCUS || message == WM_KILLFOCUS)
  590.         {
  591.         RECT r;
  592.         HDC hDC;
  593.         HPEN hPen;
  594.  
  595.         hDC = GetDC(hWnd);
  596.         GetClientRect(hWnd,&r);
  597.         hPen = SelectObject(hDC, CreatePen(PS_DOT,0,
  598.             (message == WM_SETFOCUS ? 0L : 0x00ffffff)));
  599.         Rectangle(hDC,r.left-MYBORDER,r.top-MYBORDER,r.right+MYBORDER,
  600.             r.bottom+MYBORDER);
  601.         DeleteObject(SelectObject(hDC,hPen));
  602.         ReleaseDC(hWnd,hDC);
  603.         GetWindowRect(hWnd,&r);
  604.         ScreenToClient(WinColorDlg,(LPPOINT)&r);
  605.         RePaintRect(MAKELONG(r.left,r.top));
  606.         if(message == WM_KILLFOCUS)
  607.             LastWindowPtr = NULL;
  608.         }
  609.     return CallWindowProc(OldRectProc,hWnd,message,wParam,lParam);
  610.     }
  611.  
  612. void InitRectProc(HWND hWnd)
  613.     {
  614.     static HWND firstWnd = 0;
  615.  
  616.     if(firstWnd == 0)
  617.         firstWnd = hWnd;
  618.     else if(firstWnd == hWnd)
  619.         {
  620.         init2 = TRUE;
  621.         return;
  622.         }
  623.     OldRectProc = (FARPROC)GetWindowLong(hWnd, GWL_WNDPROC);
  624.     SetWindowLong(hWnd,GWL_WNDPROC,(LONG)RectProcPtr);
  625.     }
  626.  
  627. // saves the current system colors into OrgColorVals
  628. void SaveOrgColors(void)
  629.     {
  630.     int i;
  631.  
  632.     for(i = 0; i < 19; i++)
  633.         OrgColorVals[i] = GetSysColor(i);
  634.     }
  635.  
  636. void SetColors(void)
  637.     {
  638.     int i;
  639.     DWORD ColorVals[19];
  640.     CRECT *start = &CRects[CRECTS_SYSCOLORS];
  641.  
  642.     for(i = 0; i < 19; i++, start++)
  643.         ColorVals[i] = start->color;
  644.  
  645.     SetSysColors(19,(LPINT)colorIndex,(DWORD FAR *)ColorVals);
  646.     }
  647.  
  648. void SetColorsFromWinColors(void)
  649.     {
  650.     int i;
  651.     DWORD ColorVals[19];
  652.     CRECT *start = &CRects[57];
  653.  
  654.     for(i = 0; i < 19; i++, start++)
  655.         ColorVals[i] = start->color;
  656.  
  657.     SetSysColors(19,(LPINT)colorIndex,(DWORD FAR *)ColorVals);
  658.     }
  659.  
  660. void RestoreColors(BOOL reset)
  661.     {    
  662.     int i;
  663.     CRECT *start = &CRects[CRECTS_SYSCOLORS];
  664.  
  665.     for(i = 0; i < 19; i++, start++)
  666.         start->color = OrgColorVals[i];
  667.  
  668.     if(reset)
  669.         SetSysColors(19,(LPINT)colorIndex,(DWORD FAR *)OrgColorVals);
  670.     }
  671.  
  672. void SaveColorsToIni(BOOL changecursor)
  673.     {
  674.     int i,hdl;
  675.     char buf[40], *section = "[WinColor]\r\n";
  676.     char name[144];
  677.     OFSTRUCT OfStruct;
  678.  
  679.     if(changecursor)
  680.         SetCursor(hHourGlassCursor);
  681.  
  682.     strcpy(name,szWinColorIni);
  683.     MakeWinDirFileName(name);
  684.     if((hdl = OpenFile(name,&OfStruct,
  685.         OF_CREATE | OF_WRITE | OF_SHARE_DENY_WRITE)) == -1)
  686.         {
  687.         if(changecursor)
  688.             SetCursor(hNormalCursor);
  689.         sprintf(buf,"Unable to update %s",szWinColorIni);
  690.         MessageBox(WinColorDlg,buf,szWinColor,MB_ICONEXCLAMATION);
  691.         return;
  692.         }
  693.     write(hdl,section,strlen(section));
  694.     sprintf(buf,"%s=%d\r\n",szAutoSave,(AutoSave ? 1 : 0));
  695.     write(hdl,buf,strlen(buf));
  696.     sprintf(buf,"%s=%d\r\n",szAutoLoad,(AutoLoad ? 1 : 0));
  697.     write(hdl,buf,strlen(buf));
  698.     sprintf(buf,"%s=%d\r\n",szAutoPilot,(AutoPilot ? 1 : 0));
  699.     write(hdl,buf,strlen(buf));
  700.     sprintf(buf,"%s=%d\r\n",szAutoUpdate,(AutoUpdate ? 1 : 0));
  701.     write(hdl,buf,strlen(buf));
  702.  
  703.     for(i = 0; i < MAX_DLGRECTS; i++)
  704.         {
  705.         sprintf(buf,"color%02d=%010lu\r\n",i,CRects[i].color);
  706.         write(hdl,buf,strlen(buf));
  707.         }
  708.  
  709.     for( ; i < MAXRECTS; i++)
  710.         {
  711.         CRects[i].color = GetSysColor(i-57);
  712.         sprintf(buf,"color%02d=%010lu\r\n",i,CRects[i].color);
  713.         write(hdl,buf,strlen(buf));
  714.         }
  715.     _lclose(hdl);
  716.     SaveOrgColors();
  717.     Set = FALSE;
  718.     if(changecursor)
  719.         SetCursor(hNormalCursor);
  720.     }
  721.  
  722.  
  723. BOOL IniFile(char *filename,WORD operation)
  724.     {
  725.     char name[144];
  726.     OFSTRUCT OfStruct;
  727.     int hdl;
  728.  
  729.     strcpy(name,filename);
  730.     MakeWinDirFileName(name);
  731.     if((hdl = OpenFile(name,&OfStruct,operation)) == -1)
  732.         return FALSE;
  733.     _lclose(hdl);
  734.     return TRUE;
  735.     }
  736.  
  737. char *MakeWinDirFileName(char *filename)
  738.     {
  739.     char name[20];
  740.  
  741.     strcpy(name,filename);
  742.     GetWindowsDirectory(filename,144);
  743.     if(LastChar(filename) != '\\')
  744.         strcat(filename,"\\");
  745.     strcat(filename,name);
  746.     return filename;
  747.     }
  748.  
  749.  
  750. void GetColorsFromIni(void)
  751.     {    
  752.     int i;
  753.     char key[10], value[15];
  754.  
  755.     AutoSave = GetPrivateProfileInt(szWinColor,szAutoSave,0,szWinColorIni);
  756.     AutoLoad = GetPrivateProfileInt(szWinColor,szAutoLoad,0,szWinColorIni);
  757.     AutoPilot = GetPrivateProfileInt(szWinColor,szAutoPilot,0,szWinColorIni);
  758.     AutoUpdate = GetPrivateProfileInt(szWinColor,szAutoUpdate,0,szWinColorIni);
  759.  
  760.     if(IniFile(szWinColorIni,OF_EXIST))
  761.         {
  762.         char def[15];
  763.         DWORD defval;
  764.  
  765.         SetCursor(hHourGlassCursor);
  766.         for(i = 0; i < MAX_DLGRECTS; i++)
  767.             {
  768.             sprintf(key,"color%02d",i);
  769.             GetPrivateProfileString(szWinColor,key,"01677215",value,
  770.                 sizeof(value),szWinColorIni);
  771.             CRects[i].color = atol(value);
  772.             }
  773.         for( ; i < MAXRECTS; i++)
  774.             {
  775.             sprintf(key,"color%02d",i);
  776.             defval = GetSysColor(i-57);
  777.             sprintf(def,"%lu",defval);
  778.             GetPrivateProfileString(szWinColor,key,def,value,
  779.                 sizeof(value),szWinColorIni);
  780.             CRects[i].color = atol(value);
  781.             }
  782.         SetColorsFromWinColors();        
  783.         SetCursor(hNormalCursor);
  784.         }        
  785.     SaveOrgColors();
  786.     }
  787.  
  788. void UpdateSystemMenu(void)
  789.     {
  790.     HMENU hSysMenu = GetSystemMenu(WinColorDlg,0);
  791.  
  792.     RemoveMenu(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
  793.     RemoveMenu(hSysMenu, SC_SIZE, MF_BYCOMMAND);
  794.  
  795.     AppendMenu(hSysMenu, MF_SEPARATOR, 0, NULL);
  796.     AppendMenu(hSysMenu, MF_STRING, SC_ABOUT, szAbout);
  797.     AppendMenu(hSysMenu, MF_STRING, SC_AUTOSAVE, szAutoSave);
  798.     AppendMenu(hSysMenu, MF_STRING, SC_AUTOLOAD, szAutoLoad);
  799.     AppendMenu(hSysMenu, MF_STRING, SC_AUTOPILOT, szAutoPilot);
  800.     AppendMenu(hSysMenu, MF_STRING, SC_AUTOUPDATE, szAutoUpdate);
  801.     }
  802.  
  803.  
  804. // paints the Color Work Area with the color of the rectangle pointed-to
  805. void PaintWorkArea(LONG lParam)
  806.     {    
  807.     POINT point = MAKEPOINT(lParam);
  808.     int i;
  809.  
  810.     for(i = 1; i < MAX_DLGRECTS; i++)
  811.         if(PtInRect(&CRects[i].r,point))
  812.             {
  813.             _PaintWorkArea(CRects[i].color, TRUE);
  814.             break;
  815.             }
  816.     }
  817.  
  818. // paints the Color Work area the specified color and sets the scroll-bars
  819. void _PaintWorkArea(DWORD color, BOOL paintrects)
  820.     {
  821.     if(paintrects)
  822.         _PaintCombo(color);
  823.     SetScrollPos(hRedScroll,SB_CTL,GetRValue(color),TRUE);
  824.     SetScrollPos(hGreenScroll,SB_CTL,GetGValue(color),TRUE);
  825.     SetScrollPos(hBlueScroll,SB_CTL,GetBValue(color),TRUE);
  826.     SetScrollValues();
  827.     }
  828.  
  829.  
  830. void SetScrollValues(void)
  831.     {
  832.     char temp[5];
  833.  
  834.     sprintf(temp,"%03d",GetScrollPos(hRedScroll,SB_CTL));
  835.     SetDlgItemText(WinColorDlg,122,temp);
  836.  
  837.     sprintf(temp,"%03d",GetScrollPos(hGreenScroll,SB_CTL));
  838.     SetDlgItemText(WinColorDlg,123,temp);
  839.  
  840.     sprintf(temp,"%03d",GetScrollPos(hBlueScroll,SB_CTL));
  841.     SetDlgItemText(WinColorDlg,124,temp);
  842.     }
  843.  
  844.  
  845. // paints the Color Work Area and the Selected Color Rectangle
  846. void _PaintCombo(DWORD color)
  847.     {
  848.     _PaintRect(&WorkArea,color);
  849.     _PaintRect(&SelectedColor,color);
  850.     }
  851.  
  852. // paints the Selected Color Rectange the color of the rectangle pointed-to
  853. void SelectColor(LONG lParam)
  854.     {
  855.     POINT point = MAKEPOINT(lParam);
  856.     int i;
  857.  
  858.     for(i = 1; i < MAX_DLGRECTS; i++)
  859.         if(PtInRect(&CRects[i].r,point))
  860.             {
  861.             _PaintRect(&SelectedColor,CRects[i].color);
  862.             break;
  863.             }
  864.     }
  865.  
  866. // paints the pointed-to rectangle the selected color
  867. void PaintRectSelectedColor(LONG lParam)
  868.     {
  869.     POINT point = MAKEPOINT(lParam);
  870.     int i;
  871.  
  872.     for(i = 1; i < MAX_DLGRECTS; i++)
  873.         if(PtInRect(&CRects[i].r,point))
  874.             {
  875.             _PaintRect(&(CRects[i]),SelectedColor.color);
  876.             break;
  877.             }
  878.     }
  879.  
  880. // re-paints pointed-to Rectangle
  881. void RePaintRect(LONG lParam)
  882.     {
  883.     POINT point = MAKEPOINT(lParam);
  884.     int i;
  885.  
  886.     for(i = 1; i < MAX_DLGRECTS; i++)
  887.         if(PtInRect(&CRects[i].r,point))
  888.             {
  889.             _PaintRect(&(CRects[i]),CRects[i].color);
  890.             LastWindowPtr = &CRects[i];
  891.             break;
  892.             }
  893.     }
  894.  
  895.  
  896.  
  897. // paints a rectangle a color
  898. void _PaintRect(CRECT *crect, DWORD color)
  899.     {
  900.     HBRUSH Old,Temp;
  901.     RECT *rect = &crect->r;
  902.     HDC hDC = GetDC(WinColorDlg);
  903.  
  904.     Temp = CreateSolidBrush((crect->solidonly ? GetNearestColor(hDC,color) :
  905.         color));
  906.     Old = SelectObject(hDC,Temp);
  907.     Rectangle(hDC,rect->left,rect->top,rect->right,rect->bottom);
  908.     SelectObject(hDC,Old);
  909.     DeleteObject(Temp);
  910.     if(crect == &SelectedColor)
  911.         _PaintSolidRect(color);
  912.     ReleaseDC(WinColorDlg,hDC);
  913.     crect->color = color;
  914.     }
  915.  
  916. // paints the rectangles in the Dialog
  917. void DlgPaint(HWND hWnd)
  918.     {
  919.     PAINTSTRUCT ps;
  920.     int i;
  921.     HDC hDC = BeginPaint(hWnd,&ps);
  922.     HBRUSH Old, Temp;
  923.     DWORD color;
  924.  
  925.     SetBkMode(hDC,TRANSPARENT);         // has to be for back ground dithering
  926.  
  927.     for(i = 0; i < MAX_DLGRECTS; i++)
  928.         {
  929.         color = (CRects[i].solidonly ? GetNearestColor(hDC,CRects[i].color)
  930.                 : CRects[i].color);
  931.         Temp = CreateSolidBrush(color);
  932.         Old = SelectObject(hDC,Temp);
  933.         Rectangle(hDC,CRects[i].r.left,CRects[i].r.top,CRects[i].r.right,
  934.             CRects[i].r.bottom);
  935.         SelectObject(hDC,Old);
  936.         DeleteObject(Temp);
  937.         }
  938.     _PaintSolidRect(CRects[0].color);
  939.     EndPaint(hWnd,&ps);
  940.     }
  941.  
  942.    // processes color-setting horizontal scroll bars
  943. void HScroll(WORD wParam, LONG lParam)
  944.     {
  945.     HWND hsb;
  946.     short color;
  947.  
  948.     hsb = HIWORD(lParam);
  949.     color = GetScrollPos(hsb,SB_CTL);
  950.  
  951.     switch(wParam)
  952.         {
  953.         case SB_PAGEDOWN:
  954.             color += 16;       // fall thru
  955.         case SB_LINEDOWN:
  956.             color++;
  957.             break;
  958.         case SB_PAGEUP:
  959.             color -= 16;       // fall thru
  960.         case SB_LINEUP:
  961.             color--;
  962.             break;
  963.         case SB_TOP:
  964.             color = 0;
  965.             break;
  966.         case SB_BOTTOM:
  967.             color = 255;
  968.             break;
  969.         case SB_THUMBPOSITION:
  970.         case SB_THUMBTRACK:
  971.             color = LOWORD(lParam);
  972.             break;
  973.         }
  974.  
  975.     SetScrollPos(hsb,SB_CTL,color,TRUE);
  976.     }
  977.  
  978. char outbuf[MAXWINDOWSPARM];
  979.  
  980. void Auto_load(void)
  981.     {
  982.     char *p;
  983.  
  984.     GetProfileString("windows","load",NULL,outbuf,sizeof(outbuf));
  985.     strupr(outbuf);
  986.  
  987.     AutoLoad = !AutoLoad;
  988.  
  989.         // if Auto Load is selected and app name is not in LOAD= list
  990.     if(AutoLoad && !strstr(outbuf,szWinColor))
  991.         {
  992.         strcpy(outbuf,szAppName);               // put WinColor in buffer
  993.         strcat(outbuf," ");                     // add blank and name to it
  994.         p = &LastChar(outbuf);                  // goto last character
  995.         p++;                                    // set to the NULL
  996.                                                 // append LOAD= list
  997.         GetProfileString("windows","load",NULL,p,sizeof(outbuf)-(p-outbuf));
  998.         WriteProfileString("windows","load",outbuf);
  999.         }
  1000.         // if Auto Load is not selected and app name is in LOAD= list
  1001.     if(!AutoLoad && (p = strstr(outbuf,szAppName)))
  1002.         {
  1003.         *p = '\0';                              // NULL at start of appname
  1004.         p += strlen(szAppName);                 // move past appname
  1005.         strcat(outbuf,p);                       // copy everybody up
  1006.         WriteProfileString("windows","load",outbuf);
  1007.         }
  1008.     }
  1009.  
  1010.  
  1011. char *WinIniKeys[MAX_WININICOLORS] =
  1012.     {
  1013.     "Scrollbar",
  1014.     "Background",
  1015.     "ActiveTitle",
  1016.     "InactiveTitle",
  1017.     "Menu",
  1018.     "Window",
  1019.     "WindowFrame",
  1020.     "MenuText",
  1021.     "WindowText",
  1022.     "TitleText",
  1023.     "ActiveBorder",
  1024.     "InactiveBorder",
  1025.     "AppWorkspace",
  1026.     "Hilight",
  1027.     "HilightText",
  1028.     "ButtonFace",
  1029.     "ButtonShadow",
  1030.     "GrayText",
  1031.     "ButtonText"
  1032.     };
  1033.  
  1034.  
  1035. void UpdateWinIni(void)
  1036.     {
  1037.     int i;
  1038.     char buf[15];
  1039.  
  1040.     for(i = 0; i < MAX_WININICOLORS; i++)
  1041.         {
  1042.         sprintf(buf,"%d %d %d",
  1043.             GetRValue(GetSysColor(i)),
  1044.             GetGValue(GetSysColor(i)),
  1045.             GetBValue(GetSysColor(i)));
  1046.         WriteProfileString("colors",WinIniKeys[i],buf);
  1047.         }
  1048.     }
  1049.  
  1050. void _PaintSolidRect(DWORD color)
  1051.     {
  1052.     HDC hDC = GetDC(WinColorDlg);
  1053.     HBRUSH Temp, Old;
  1054.  
  1055.     DWORD x = GetNearestColor(hDC,color);
  1056.     
  1057.     Temp = CreateSolidBrush(x); //RGB(red,green,blue));
  1058.     Old = SelectObject(hDC,Temp);
  1059.     Rectangle(hDC,SolidRect.left,SolidRect.top,SolidRect.right,SolidRect.bottom);
  1060.     SelectObject(hDC,Old);
  1061.     DeleteObject(Temp);
  1062.     ReleaseDC(WinColorDlg,hDC);
  1063.     }
  1064.  
  1065.  
  1066. BOOL FAR PASCAL _export DialogProc(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
  1067.     {
  1068.     lParam = lParam;        // turn off compiler warning
  1069.  
  1070.     switch(message)
  1071.         {
  1072.         case WM_INITDIALOG:
  1073.             return TRUE;
  1074.  
  1075.         case WM_COMMAND:
  1076.             if(wParam == IDOK || wParam == IDCANCEL)
  1077.                 {
  1078.                 EndDialog(hDlg, TRUE);
  1079.                 return TRUE;
  1080.                 }
  1081.             break;
  1082.         }
  1083.     return FALSE;
  1084.     }
  1085.  
  1086. void initRECT(RECT *r, float x, float y)
  1087.     {
  1088.     float temp;
  1089.  
  1090.     temp = (float)r->left;
  1091.     temp *= x;
  1092.     temp /= (float)4;
  1093.     r->left = (WORD)temp;
  1094.     if((temp-r->left) > 0)
  1095.         r->left++;
  1096.  
  1097.     temp = (float)r->top;
  1098.     temp *= y;
  1099.     temp /= (float)8;
  1100.     r->top = (WORD)temp;
  1101.     if((temp-r->top) > 0)
  1102.         r->top++;
  1103.  
  1104.     temp = (float)r->right;
  1105.     temp *= x;
  1106.     temp /= (float)4;
  1107.     r->right = (WORD)temp;
  1108.     if((temp-r->right) > 0)
  1109.         r->right++;
  1110.  
  1111.     temp = (float)r->bottom;
  1112.     temp *= y;
  1113.     temp /= (float)8;
  1114.     r->bottom = (WORD)temp;
  1115.     if((temp-r->bottom) > 0)
  1116.         r->bottom++;
  1117.     }
  1118.  
  1119.  
  1120. void InitArray(void)
  1121.     {
  1122.     int i;
  1123.     float x,y;
  1124.     LONG l = GetDialogBaseUnits();
  1125.     CRECT *start = &CRects[CRECTS_SYSCOLORS];
  1126.  
  1127.     x = LOWORD(l);
  1128.     y = HIWORD(l);
  1129.  
  1130.     for(i = 0; i < 19; i++, start++)
  1131.         {
  1132.         start->color = GetSysColor(i);
  1133.         initRECT(&start->r,x,y);
  1134.         }
  1135.     for(i = 0; i < MAX_CUSTCOLORS; i++, start++)
  1136.         initRECT(&start->r,x,y);
  1137.  
  1138.     initRECT(&SelectedColor.r,x,y);
  1139.     initRECT(&WorkArea.r,x,y);
  1140.     initRECT(&SolidRect,x,y);
  1141.     GetColorsFromIni();
  1142.     }
  1143.  
  1144.  
  1145.  
  1146.